<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 16-12-5
 * Time: 下午9:26
 */
namespace app\wateradmin\controller;

use app\common\controller\BaseAdmin;
use think\Model;

class Admingoods extends BaseAdmin{
    /*
     * 后台首页
     * 赵坤
     * 20161206
     * */
    public function index(){
        $this->assign('title','拼图云商品管理');
        $this->assign('description','拼图云商城');

//        model('ShopGoods')->getGoodsList($condition, $field = '*', $group = '',$order = '', $limit = 0, $page = 0, $lock = false, $count = 0);
        return $this->fetch();
    }
    /*
     * 商品添加
     * 赵坤
     * 20161206
     * */
    public function add(){
        $this->assign('title','拼图云商品管理');
        $this->assign('description','拼图云商城');
        if($this->request->isPost()){
            $goodsimg = $this->request->param('goods_image');
            if(is_array($goodsimg)&&!empty($goodsimg)){
                $goodsimg = serialize($goodsimg);
            }
            $goodsinfo = array(
                'store_id'=>session('store_id')?session('store_id'):0,
                'seller_id'=>session('shop'),
                'supplier_id'=>session('supplier_id')?session('supplier_id'):0,
                'goods_name'=>trim($this->request->param('goods_name')),
                'category_id'=>intval($this->request->param('category_id')),
                'goods_price'=>floatval($this->request->param('goods_price')),
                'goods_marketprice'=>floatval($this->request->param('goods_marketprice')),
                'goods_serial'=>trim($this->request->param('goods_serial')),
                'goods_storage_alarm'=>intval($this->request->param('goods_storage_alarm')),
                'goods_salenum'=>intval($this->request->param('goods_salenum')),
                'goods_spec'=>'',
                'goods_storage'=>intval($this->request->param('goods_shipping')),
                'goods_image'=>$goodsimg,
                'goods_shipping'=>$this->request->param('goods_shipping'),
                'goods_state'=>1,
                'goods_verify'=>1,
                'goods_addtime'=>time(),
                'goods_edittime'=>time()
            );
        }
        $goodsclass = cache('goodsclass'.session('shop'));
        $this->assign('goodsclass',$goodsclass);
        return $this->fetch();
    }
    /*
         * 下架商品
         * 赵坤
         * 20161206
         * */
    public function downgoods(){
        $this->assign('title','拼图云商品管理');
        $this->assign('description','拼图云商城');

        return $this->fetch();
    }
    /*
      * 商品售罄
      * 赵坤
      * 20161206
      * */
    public function saledgoods(){
        $this->assign('title','拼图云售罄商品');
        $this->assign('description','拼图云商城');

        return $this->fetch();
    }
    /*
      * 商品回收站
      * 赵坤
      * 20161206
      * */
    public function trashgoods(){
        $this->assign('title','拼图云商品回收站');
        $this->assign('description','拼图云商城');

        return $this->fetch();
    }
    /*
      * 商品编辑
      * 赵坤
      * 20161206
      * */
    public function editgoods(){
        $this->assign('title','拼图云商品编辑');
        $this->assign('description','拼图云商城');

        return $this->fetch();
    }
    /*
      * 商品删除
      * 赵坤
      * 20161206
      * */
    public function delgoods(){
        $this->assign('title','拼图云商品删除');
        $this->assign('description','拼图云商城');

        return $this->fetch();
    }
    /*
      * 商品下架
      * 赵坤
      * 20161206
      * */
    public function goodsdown(){
        $this->assign('title','拼图云商品下架');
        $this->assign('description','拼图云商城');

        return $this->fetch();
    }
}